<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>邀请会员</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/chosen/chosen.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
    <link href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css" rel="stylesheet">
    <style type="text/css">
	body{font-size: 14px;}
		a{color:black;padding: 0 8px;}
		a:hover{color:#1ab394;}
		a.currentNode{color:#1ab394;}
		.radio{margin-top: 0;}
		.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
	</style>
</head>
<body class="gray-bg">

	
<div class="container-fluid">

		<div class="col-sm-12" style="height:80px;">
               <h4><a href="staffList.html" onclick="javascript:location.replace(this.href);event.returnValue=false;">员工列表></a><span id="liename"></span>>邀请会员</h4>
        </div>
        <div class="couton" style="padding: 10px,0,0,0">
			<button type="button" class="btn btn-default btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('1')">员工概况</button>
			<button type="button" class="btn btn-info btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('2')">积分记录</button>      
			<button type="button" class="btn btn-info btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('3')">邀请粉丝</button>      
			<button type="button" class="btn btn-info btn-lg" style="background-color: white;color: black;border:none;" onclick="messagestaff('4')">邀请会员</button>      
		</div>
	 <div class="row" style="background-color: white;">
    	<div class="col-sm-4">
        </div>
        <div class="col-sm-8 text-right">
            	<a id="export" href="javascript:void(0)">
            	<button class="btn btn-primary" type="button">导出CSV</button>
      			</a>
        </div>
    </div>
    <!--列表头  -->
    <div class="wt100" style="position:relative; overflow:hidden; height:100%">
	        <table id="myTable" class="display" cellspacing="0" width="100%">
	            <thead>
	            <tr>
	            	<th style="width:30px; padding:10px 0 10px 10px">
		            	<input type="checkbox" id="checkall">
		            </th>
	                <th>姓名</th>
	                <th>电话</th>
	                <th>OpeanId</th>
	                <th>注册时间</th>
	            </tr>
	            </thead>
	            <tbody>   
	            </tbody>
	        </table>
    </div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/dateUtils.js"></script>  
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<script type="text/javascript">
$.fn.dataTable.ext.errMode = 'none';
var path = "<%=path%>";
var staffId = getUrlParam("id");
var name = decodeURI(getUrlParam("name"));

    $(function () {
    	$("#liename").text(name);
        init();
    });
    
    function getUrlParam(key){
    	var reg = new RegExp("(^|&)"+ key +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }	
    /*页面跳转  */
    function messagestaff(id){
    	var name = $("#liename").text();
		if(id == 1){
			window.location.href="<%=path%>/view/ui/staffdetails?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else if(id == 2){
			window.location.href="<%=path%>/view/ui/integralrecord?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else if(id == 3){
			window.location.href="<%=path%>/view/ui/invitingfans?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else{
			window.location.href="<%=path%>/view/ui/invitingmembers?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}
    }
    
    
	/* 初始化页面 */
    function init() {
        myDataTable = dataTable();
    }

    $("#export").click(function(){
		var href = path+"/staff/exportInvitingMember?staffId="+staffId;
		$(this).attr("href",href);
	});
  

    function func_dataTableReload() {
    	if(func_valid()){
	        myDataTable.ajax.reload();
    	}
    }

    function func_AjaxUrl() {
          return path + "/staff/ajaxInvitingMemberList";  
    }

    function func_columns() {
        var jsonArr = [
            {"data": "id"},
            {"data": "name"},
            {"data": "phone"},
            {"data": "openId"},
            {"data": "registTime"},
        ];
        return jsonArr;
    }

    function func_ajaxData() {
    	 var jsonObject = new Object();
         jsonObject.staffId=staffId
        return jsonObject;
    }

    function dataTable() {
        return $('#myTable').DataTable({
            processing: true,
            searching: false,
            ordering:true,
            bFilter:true,
            info: true,
            autoWidth: true,
            lengthChange: false,
            language: {
                emptyTable: '没有数据表',
                info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
                infoEmpty: '没有数据',
                lengthMenu: '每页显示 _MENU_ 条记录',
                loadingRecords: '正在加载数据....',
                processing: '正在处理数据....',
                zeroRecords: '没有找到匹配的记录',
                paginate: {
                    first: '首页',
                    previous: '前页',
                    next: '后页',
                    last: '尾页'
                }
            },
            order: [[4, 'desc']],
            pageLength: 20,
            pagingType: 'full_numbers',
            
            columnDefs: [{
                render: function (data, type, full) {
                     var result = "";
                    if (data != null) {
                        result = '<input class="checkbox_select" type="checkbox" value="'+data+'"/>';
                    }
                    return result; 
                },
                targets: 0
            	},{
                render: function (data, type, full) {
                    var result = "";
                    if (data == null) {
                        result = "——";
                    } else {
                    	if(full.photo == null){
                    		result='<img style="width:20px;float:left;margin-top:20px;" class="card_click" >' 
                                + '<img style="height:30px;width:30px;margin:0 0 0 6px;border-radius:50%;" onerror="loadDefalutImage(this)" src="'+path+'/images/aem/memberImg001.png">&nbsp;&nbsp;'
                             	+  '<font color="#515151">'+full.name+'</font></a>'; 
                    	}else{
                    	result='<img style="width:20px;float:left;margin-top:20px;" class="card_click" >' 
                            + '<img style="height:30px;width:30px;margin:0 0 0 6px;border-radius:50%;" onerror="loadDefalutImage(this)" src="'+full.photo+'">&nbsp;&nbsp;'
                         	+  '<font color="#515151">'+full.name+'</font></a>'; 
                    	}
                    }
                    return result;
                },
                targets: 1,
            }, {
                render: function (data, type, full) {
                    var result = "";
                    if (data == null) {
                        result = "——";
                    } else {
                        result = data;
                    }
                    return result;
                },
                targets: 2,
            },{
                render: function (data, type, full) {
                    var result = "";
                    if (data == null) {
                        result = "——";
                    } else {
                        result = data;
                    }
                    return result;
                },
                targets:3,
            },  {
                render: function (data, type, full) {
                    var result = "";
                     if (data == null) {
                         result = "——";
                     } else {
                    	 result = ""+formatDateTimeYMDHMS(data)
                     }
                    return result;
                },
                targets: 4,
            }],
            columns: func_columns(),
            serverSide: true,
            ajax: {
                contentType: 'application/json;charset=utf-8',
                type: 'POST',
                url: func_AjaxUrl(),
                data: function (d) {
                    d.extra_search = func_ajaxData();
                    return JSON.stringify(d);
                }
            }
        });
    }

	//验证
	function func_valid(){
		var point1 = $("#point1").val();
		var point2 = $("#point2").val();
		if($("a[point]:last").hasClass("cfoucs") && point1!='' && point2!=''){
			point1 = parseInt(point1);
			point2 = parseInt(point2);
			if(point1 > point2){
				var d = dialog({
					align: 'right',
					content: '第二个值应比第一个值大'
				}).show($("#point2")[0]);
				setTimeout(function () {
					d.close().remove();
				}, 1600);
				return false;
			}
		}
		
		return true;
	}
	
	
	
</script>
</html>